package com.denlaku.longan.service.impl;

import com.denlaku.longan.qo.DataPermQuery;
import com.denlaku.longan.qo.Query;
import com.denlaku.longan.repository.DataTagPackRepository;
import com.denlaku.longan.service.DataTagSetService;
import com.denlaku.longan.service.DataTagRelService;
import com.denlaku.longan.service.DataTagPackService;
import com.denlaku.longan.service.DataTagService;
import com.denlaku.longan.vo.DataTagPack;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author tianx
 */
@Slf4j
@Service
public class DataTagPackServiceImpl implements DataTagPackService {
    @Autowired
    private DataTagPackRepository dataTagPackRepository;

    @Autowired
    private DataTagService dataTagService;

    @Autowired
    private DataTagSetService dataPermPackService;

    @Autowired
    private DataTagRelService dataTagRelService;

    @Override
    public void add(DataTagPack dataTagPack) {
        dataTagPackRepository.add(dataTagPack);
    }

    @Override
    public void update(DataTagPack dataTagPack) {
        dataTagPackRepository.update(dataTagPack);
    }

    @Override
    public DataTagPack get(Query query) {
        return dataTagPackRepository.get(query);
    }

    @Override
    public List<DataTagPack> list(Query query) {
        return dataTagPackRepository.list(query);
    }

    @Override
    public List<DataTagPack> search(Query query) {
        return dataTagPackRepository.search(query);
    }

    @Override
    public void delete(DataPermQuery query) {
        dataTagPackRepository.delete(query);
        query.setTagPackId(query.getId());
        query.setId(null);
        dataTagService.delete(query);
        dataPermPackService.delete(query);
        dataTagRelService.delete(query);
    }
}
